package com.hetrone.machine.graph;

import java.util.List;

public abstract class Graph<T> {
	/**
	 * 顶点个数
	 */
	private Integer n;
	/**
	 * 边个数
	 */
	private Integer m = 0;
	/**
	 * 有向图还是无向图
	 */
	private boolean directed;
	/**
	 * 图
	 */
	private List<List<T>> g;

	public Integer getN() {
		return n;
	}

	public Integer getM() {
		return m;
	}

	protected void increaseM() {
		m++;
	}

	public boolean isDirected() {
		return directed;
	}

	public List<List<T>> getG() {
		return g;
	}

	public Graph(Integer n, Boolean directed) {
		super();
		this.n = n;
		this.directed = directed;
		this.g = init();
	}

	/**
	 * 初始化图
	 */
	public abstract List<List<T>> init();

	/**
	 * 添加边
	 * 
	 * @param v
	 * @param w
	 */
	public abstract void addEdge(Integer v, Integer w);

	/**
	 * 顶点v到订单w是否存在边
	 * 
	 * @param v
	 * @param w
	 */
	public abstract Boolean hasEdge(Integer v, Integer w);

}
